package binary;
/** 补码的演示 */
public class ComplementDemo {
    public static void main(String[] args) {
        //规律数：
        int max = Integer.MAX_VALUE;//int的最大值
        int min = Integer.MIN_VALUE;//int的最小值
        System.out.println(Integer.toBinaryString(max));//0111....31个1
        System.out.println(Integer.toBinaryString(min));//1000...31个0
        System.out.println(Integer.toBinaryString(-1));//1111...32个1
        System.out.println(max);
        System.out.println(min);
        long max2 = Long.MAX_VALUE;//long的最大值
        long min2 = Long.MIN_VALUE;//long的最小值
        System.out.println(Long.toBinaryString(max2));//0111...63个1
        System.out.println(Long.toBinaryString(min2));//1000...63个0

        //负值的演示
        int n = -45;
        System.out.println(n);//-45，-1减去对应位置上的权
        System.out.println(Integer.toBinaryString(n));//11111111111111111111111111010011
    }
}
